package com.learn.project2.controller.admin;

import com.learn.project2.model.bo.admin.brand.BrandCreateBO;
import com.learn.project2.model.bo.admin.brand.BrandDeleteBO;
import com.learn.project2.model.bo.admin.brand.BrandListBO;
import com.learn.project2.model.bo.admin.brand.BrandUpdateBO;
import com.learn.project2.model.vo.admin.brand.BrandCreateVO;
import com.learn.project2.model.vo.admin.brand.BrandListVO;
import com.learn.project2.model.vo.admin.brand.BrandUpdateVO;
import com.learn.project2.service.admin.brand.BrandService;
import com.learn.project2.utils.Result;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @description: 商场管理-品牌制造商
 * @author 亓永杰
 * @date 2022-01-06 21:32
 * @version 1.0
 */
@RestController
@RequestMapping("admin/brand")
public class BrandController {

    @Autowired
    BrandService brandService;
/**
 * @description: 查询品牌
 * @param: BrandListBO
 * @return: Result
 * @author 亓永杰
 * @date: 2022-01-08 10:01
 */
    @RequestMapping("list")
    @RequiresPermissions("admin:brand:list")
    public Result list(BrandListBO brandListBO){
        BrandListVO brandListVO = brandService.listBrands(brandListBO);
        return Result.ok(brandListVO);
    }

/**
 * @description: 添加品牌商
 * @param:  BrandCreateBO
 * @return:  Result
 * @author 亓永杰
 * @date: 2022-01-08 10:30
 */
    @RequestMapping("create")
    @RequiresPermissions("admin:brand:create")
    public Result create(@RequestBody BrandCreateBO brandCreateBO){
        BrandCreateVO brandCreateVO = brandService.insertBrand(brandCreateBO);
        return Result.ok(brandCreateVO);
    }

/**
 * @description: 编辑品牌商
 * @param:
 * @return:  Result
 * @author 亓永杰
 * @date: 2022-01-08 11:52
 */
    @RequestMapping("update")
    @RequiresPermissions("admin:brand:update")
    public Result update(@RequestBody BrandUpdateBO brandUpdateBO){
        BrandUpdateVO brandUpdateVO = brandService.updateBrand(brandUpdateBO);
        return Result.ok(brandUpdateVO);
    }


    @RequestMapping("delete")
    @RequiresPermissions("admin:brand:delete")
    public Result delete(@RequestBody BrandDeleteBO brandDeleteBO){
        brandService.deleteBrand(brandDeleteBO);
        return Result.ok();
    }

}
